<template>
	<view class="padding30rpx">
		<view class="dis cour"  v-for="(item,index) in data" :key="index" @click="$mHelper.to('/pages/term/course/course?id='+item.curriculumid+'&pid='+item.pid)">
			<view class="cour-left">
				<image :src="item.imgs"></image>
			</view>
			<view class="cour-right">
				<view class="clamp cour-biao">{{item.curriculumname}}</view>
				<view class="dis  cour-bot" >
					<view class="cour-btn ">学习币：<label>{{item.currencynumber}}</label></view>
					<view class="cour-ju">
						<image @tap="enter(item)" src="../static/ca.png"></image>
					</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data:[]
			}
		},
		onShow() {
			this.selectUserCollection()
		},
		methods: {
			selectUserCollection(){
				uni.request({
					method:'GET',
					url:this.$api+'/app/UserController/selectUserCollection',
					header:{'token':uni.getStorageSync('token')},
					success: (res) => {
						console.log(res.data)
						if(res.data.code == 200){
							this.data = res.data.data
						}
					}
				})
			},
			//取消收藏
			enter(i){
				console.log('i',i)
				uni.request({
					method:'GET',
					url:this.$api +'/app/UserController/deleteUserCollection',
					data:{ id:i.curriculumid},
					header:{'token':uni.getStorageSync('token')},
					success: (res) => {
						console.log(res.data)
						if(res.data.code == 401 ){
							uni.navigateTo({
								url:'/pagesB/login/login'
							})
						}
						if(res.data.code == 200) {
							uni.showToast({
								icon:'none',
								title:'已取消收藏'
							})
							this.selectUserCollection()
						}
					}
				})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cour-right{
		width: 70%;
	}
	.cour{
		margin-top: 25rpx;
		position: relative;
		width: 100%;
		.cour-left{
			width: 180rpx;
			height: 180rpx;
			margin-right: 25rpx;
			image{
				width: 180rpx;
				height: 180rpx;			
				border-radius: 10rpx;
			}
		}
		.cour-biao{
			font-size: 30rpx;
			color: #333333;
		}
		
		.cour-bot{
			position: absolute;
			bottom: 0;
			width: 70%;
			.cour-ju{
				
				image{
					width: 48rpx;
					height: 48rpx;
				}
				position: absolute;
				right: 0;
			}
			.cour-btn{
				border-top-left-radius: 15rpx;
				border-bottom-right-radius: 15rpx;
				padding: 0 20rpx;
				color: #00A29A;
				height: 48rpx;
				line-height: 48rpx;
				background-color: #D9F6FF;
				
			}
		}
	}
</style>
